/* Copyright (c) 2006 by M Aamir Maniar 
 * 
 * Permission is hereby granted, free of charge, to any person obtaining 
 * a copy of this software and associated documentation files (the 
 * "Software"), to deal in the Software without restriction, including 
 * without limitation the rights to use, copy, modify, merge, publish, 
 * distribute, sublicense, and/or sell copies of the Software, and to 
 * permit persons to whom the Software is furnished to do so, subject to 
 * the following conditions:
 * 
 * The above copyright notice and this permission notice shall be 
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 * 
 * */

namespace Generics.Net.Tests
{

    using System;
    using SysGeneric = System.Collections.Generic;
    using System.Text;
    using NUnit.Framework;
    using Generic.DataStructures;
    
    [TestFixture()]
    public class LinkedQueueTester
    {

        LinkedQueue<int> _queue;
        
        public LinkedQueueTester()
        {
            Initialize();
        }

        [TestFixtureSetUp()]
        public void Initialize()
        {
            _queue = new LinkedQueue<int>();
            int[] array = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            Assert.AreEqual(_queue.Count, 0);
            for (int index = 0; index < array.Length; index++)
                _queue.Enqueue(array[index]);
            Assert.AreEqual(_queue.Count, 10);
        }
        
        [Test()]
        public void Enqueue()
        {
            int count = _queue.Count;
            _queue.Enqueue(100);
            _queue.Enqueue(200);
            Assert.AreEqual(_queue.Count, count+2);
        }

        [Test]
        public void Dequeue()
        {
            int count = _queue.Count;
            _queue.Dequeue();
            _queue.Dequeue();
            _queue.Dequeue();
            Assert.AreEqual(_queue.Count, count-3);
        }

        [Test]
        public void Clone()
        {
            LinkedQueue<int> q2 = _queue.Clone();
            q2.Dequeue();
            q2.Dequeue();
            Assert.AreNotEqual(q2.Count, _queue.Count);
            Assert.AreNotEqual(q2.First, _queue.First);
        }

        [Test]
        public void CopyTo()
        {
            _queue.Dequeue();
            
            int[] newArray = new int[100];
            _queue.CopyTo(newArray, 91);
            Assert.AreEqual(_queue.First, newArray[91]);
        }

        [Test]
        public void First()
        {
            int first = _queue.First;
            Assert.AreEqual(_queue.Dequeue(), first);
        }

        [Test]
        public void Last()
        {
            int[] newArray = _queue.ToArray();
            Assert.AreEqual(_queue.Last, newArray[_queue.Count-1]);
        }



    }
}
